/*
 * Copyright (C) 2023 Coder.AN
 * Email: an.hongjun@foxmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#ifndef __EDGETIMER_H__
#define __EDGETIMER_H__

#include <stdint.h>
#include <string>
#include <iostream>
#include <chrono>

class Timer
{
private:
    double all_time = 0;
    double count = 0;
    uint32_t count_n = 20;
    size_t once_time = 0;
    std::string name;
    std::chrono::_V2::system_clock::time_point start_time, end_time;
    
public:
    Timer(std::string name, uint32_t count_n=20);

    void start();
    void end();
    void output();

    ~Timer();
};

#endif  // __EDGETIMER_H__
